package cate.game.play.buff.h;

import cate.game.play.buff.BuffHandler;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import easy.java.struct.ref.DoubleRef;

/**
 * 分担目标受到的55%的伤害
 */
public class 援护BH extends BuffHandler {

	private double 分担比例;

	private double 减免比例;

	//分担比例=5500&减免比例=0
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		分担比例 = args.getWDouble("分担比例", 0d);
		减免比例 = args.getWDouble("减免比例", 0d);
	}

	@Override
	public void parseExt(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		减免比例 += args.getWDouble("减免比例", 0d);
	}

	@Override
	public void shareDamage(ActionCtx action, Fighter actor, int reason, DoubleRef doubleRef) {
		if (buff.caster.isDead()) {
			return;
		}
		double shareDamage = doubleRef.v * 分担比例;
		doubleRef.v -= shareDamage;
		double selfDamage = shareDamage * (1 - 减免比例);
		buff.caster.attr.shareHurt(action, actor,buff, selfDamage);
	}
}
